home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / bccapp.zip / SCROLL.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  2KB  |  122 lines

  1. /*
  2.  *
  3.  * Class Implementation for Popup menu system
  4.  *
  5.  * (C) 1990 Vision Software
  6.  *
  7.  * $Id: scroll.c 1.2001 91/04/25 15:07:59 pcalvin release $
  8.  *
  9.  * Comments:
  10.  *
  11.  * Scroll boxes.  Simple implementation due to POPUP handling most of the
  12.  * difficult operation for us.
  13.  *
  14.  * Bugs:
  15.  *
  16.  * None documented
  17.  *
  18.  */
  19. #include <stdlib.h>
  20. #include <conio.h>
  21. #include <string.h>
  22. #include <ctype.h>
  23.  
  24. #include <stdhdr.h>
  25. #include <adl.h>
  26. #include <menu.h>
  27.  
  28. /*
  29.  * Public constructors, used by the general public for
  30.  * General scroll boxes..
  31.  */
  32. SCROLL::SCROLL(ROW row,COL col,CENT cent,PENT pent,CENT centView,SZ sz) : POPUP(row,col,cent,pent,sz)
  33.     {
  34.     centTop = 0;
  35.     centViewMax = centView;
  36.     }
  37.  
  38. /*
  39.  * Displays a row, Scrolls the box if necessary.
  40.  */
  41. VOID SCROLL::Display(CENT cent,PENT pent,WINDOW &rwnd,BOOL fSelected)
  42.     {
  43.     PointerAssert(pent);
  44.     PointerAssert(pent[cent].sz);
  45.  
  46.     CO coBack = fSelected ? coGreen : coCyan;
  47.  
  48.     if (cent - centTop < centViewMax)
  49.         {
  50.         SZ sz = SzFromCentPent(cent,pent);
  51.         CCH cch = pent[cent].cchHotKey+1;
  52.  
  53.         rwnd.SayHot(cent-centTop,0,sz,cch,coBlack,coBack);
  54.         }
  55.     }
  56.  
  57. BOOL SCROLL::FHandleCd(CENT &rcent,CD cd,PENT pent,WINDOW &rwnd)
  58.     {
  59.     BOOL fContinue = fTrue;
  60.     /*
  61.      * Defaults to no exit, must prove otherwise.
  62.      */
  63.     switch (cd)
  64.         {
  65.     case cdCursorUp:
  66.         if (rcent > 0)
  67.             {
  68.             Display(rcent,pent,rwnd,fFalse);
  69.             if (rcent > centTop)
  70.                 {
  71.                 rcent -= 1;
  72.                 }
  73.             else
  74.                 {
  75.                 rwnd.ScrollDrow(-1);
  76.                 centTop -= 1;
  77.                 rcent -= 1;
  78.                 }
  79.             }
  80.         break;
  81.     case cdCursorDown:
  82.         if (rcent+1 < centMax)
  83.             {
  84.             Display(rcent,pent,rwnd,fFalse);
  85.             if (rcent+1 < centTop + centViewMax)
  86.                 {
  87.                 rcent += 1;
  88.                 }
  89.             else if (centTop + 1 < centMax)
  90.                 {
  91.                 rwnd.ScrollDrow(1);
  92.                 centTop += 1;
  93.                 rcent += 1;
  94.                 }
  95.             }
  96.         break;
  97.     default:
  98.         fContinue = POPUP::FHandleCd(rcent,cd,pent,rwnd);
  99.         break;
  100.         }
  101.  
  102.     return (fContinue);
  103.     }
  104.  
  105. VOID SCROLL::KeepInView(CENT cent)
  106.     {
  107.     if (cent < centTop)
  108.         centTop = cent;
  109.     else if (cent >= (centTop+centViewMax))
  110.         centTop = (cent - centViewMax+1);
  111.     }
  112.  
  113. ROW SCROLL::CrowFromCentPent(CENT centMac,PENT pent)
  114.     {
  115.     Assert(pent != pentNil);
  116.     Assert(pent->sz != szNil);
  117.     Assert(centViewMax <= centMac);
  118.  
  119.     return (centViewMax);
  120.     }
  121.  
  122.